Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate HasPrincipalKey on relationship if necessary #575

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DavidBoone
Copy link

Took a crack at fixing #574 and came up with this.

It resolved the issue I was having with my SQLite test case, but I'm not super familiar with the code-base so I can't be confident it's the right solution in all cases. Please review carefully!

If nothing else I hope it serves as a handy starting point for a more robust implementation.

var primaryKeys = relationship.PrimaryProperties;
var nonPrimaryPrincipalKey = !primaryKeys
.Select(pp => relationship.PrimaryEntity.Properties.ByProperty(pp.PropertyName))
.All(p => p.IsPrimaryKey ?? true);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure what IsPrimaryKey == null would mean, so I used ?? true so it would not generate the .HasPrincipalKey stuff in that case. There may be other corner-cases I haven't considered as well.

@DavidBoone DavidBoone force-pushed the 574-nonPrimaryPrincipalKey branch from 4c66530 to e77c93c Compare October 10, 2024 21:04
@DavidBoone DavidBoone force-pushed the 574-nonPrimaryPrincipalKey branch from e77c93c to 7ce664a Compare November 14, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant